home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
edsspell
/
edsspell.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
30KB
|
880 lines
(* EDSSPELL.PAS - Copyright (c) 1995-1996, Eminent Domain Software *)
unit EDSSpell;
{-Component Wrapper for Spell Dialog}
{$I SpellDef.PAS}
{-defines for EDSSpell component}
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, Menus, ExtCtrls,
SpellGbl, AbsBuff, AbsSpell, LexDCT, WPSpell,
{$IFNDEF Shareware}
MSSpell, W96Spell,
{$ENDIF}
{$IFDEF SupportOrpheus}
OvcEdit, OvcEF, OvcBuff,
{$ENDIF}
{$IFDEF SupportTXText}
TXBuff, Tx4vb,
{$ENDIF}
{$IFDEF SupportWPTools}
WPRich, WPBuff,
{$ENDIF}
SpellInt;
type
{Dialog Component Wrapper}
TSpellDlg = class (TComponent)
private
FPath: TFileName;
FDictionary: TFileName;
FDicType: TLanguages;
FLanguage: TLanguages;
FDialogType: TDialogTypes;
FSpellWin: TAbsSpellDialog;
FSuggestions: Byte;
FIcons: TAccentSet;
FAutoSuggest: Boolean;
FAutoShift: Boolean;
FHelpContext: THelpContext;
FUserDCT: TFileName;
{Lists of words}
FSkipList: TStringList; {List of words to skip}
FReplaceList: TStringList; {List of words to auto-replace}
FReplacer: TStringList; {List of words to replace above list with}
FReplaceNum: integer; {index of word in replace list}
procedure SetDicType (NewType: TLanguages);
{-sets the new dictionary type}
procedure SetLanguage (NewLanguage: TLanguages);
{-sets the language for the label}
procedure SetDialogType (NewType: TDialogTypes);
{-sets the dailog type}
procedure SetSuggestions (Num: Byte);
{-sets the number of suggestions}
procedure SetIconSet (IconSet: TAccentSet);
{-sets the icons to be visible}
procedure SetHelpContext (HelpID: THelpContext);
{-sets the help context for the spell component}
function CheckBuffer (ABuffer: TAbsBuffer): Integer;
{-checks the buffer}
public
constructor Create (AOwner: TComponent); override;
{-initializes object}
destructor Destroy; override;
{-destroys object}
function Open: Boolean;
{-opens the dictionary}
procedure Close;
{-closes the dictionary and removes the dialog}
procedure ClearLists;
{-clears the SkipList, ReplaceList, and Replacer List}
procedure MoveDialog (YPos: Integer);
{-moves the dialog so that it does not highlighted word}
procedure EnableSkipButtons;
{-enables the skip buttons on the dialog}
procedure DisableSkipButtons;
{-disables the skip buttons on the dialog}
procedure Show;
{-displays the dialog}
function CheckWord (var AWord: String): Integer;
{-checks the word (see AbsSpell for CheckWord results)}
function CheckCustomEdit (ACustomEdit: TCustomEdit): Integer;
{-checks a custom edit control}
function CheckMemo (AMemo: TMemo): Integer;
{-checks the memo}
(* function CheckDBMemo (ADBMemo: TDBMemo): Integer; *)
(* -use CheckCustomEdit instead: *)
(* CheckCustomEdit (DBMemo1); *)
function CheckEdit (AnEdit: TEdit): Integer;
{-checks a TEdit control}
{$IFDEF SupportOrpheus}
function CheckOvcEditor (AnOvcEdit: TOvcCustomEditor): Integer;
{-checks an Orpheus editor component}
function CheckOvcField (AnOvcField: TOvcBaseEntryField): Integer;
{-checks an Orpheus field component}
{$ENDIF}
{$IFDEF SupportTXText}
function CheckTXControl (ATXControl: TTextControl): Integer;
{-checks a TXTextControl}
{$ENDIF}
{$IFDEF SupportWPTools}
function CheckWPText (AWPRichText: TWPRichText): Integer;
{-checks a WPTools RTF Component}
{$ENDIF}
function CheckAllFields (AForm: TForm; DisplayMsg: Boolean): Integer;
{-checks all of the edit fields on the form}
{---- Word Counters ----}
procedure CustomEdit_WordCount (ACustomEdit: TCustomEdit; var NumWords, UniqueWords: Longint);
{-returns the number of words in a TCustomEdit}
procedure Memo_WordCount (AMemo: TMemo; var NumWords, UniqueWords: Longint);
{-returns the number of words in a TMemo}
procedure Edit_WordCount (AnEdit: TEdit; var NumWords, UniqueWords: Longint);
{-returns the number of words in a TEdit}
{$IFDEF SupportOrpheus}
procedure OvcEdit_WordCount (AnOvcEdit: TOvcCustomEditor;
var NumWords, UniqueWords: Longint);
{-returns the number of words in a TOvcCustomEditor}
procedure OvcField_WordCount (AnOvcField: TOvcBaseEntryField;
var NumWords, UniqueWords: Longint);
{-returns the number of words in a TOvcBaseEntryField}
{$ENDIF}
{$IFDEF SupportTXText}
procedure TXText_WordCount (ATXControl: TTextControl;
var NumWords, UniqueWords: Longint);
{-returns the number of words in a TX Text-Control}
{$ENDIF}
{---- Internal Routines (No Dialog) ----}
function OpenDictionary: Boolean;
{-opens the dictionary}
procedure CloseDictionary;
{-closes the dictionary}
function AddWord (AWord: string): Boolean;
{-adds a word to the dictionary, returns TRUE if successful}
function InDictionary (AWord: String): Boolean;
{-checks to see if the word is in the dictionary (no dialog)}
function SuggestWords (AWord: String; NumToList: Byte): TStringList;
{-suggests words}
{Lists of words}
property SkipList: TStringList read FSkipList write FSkipList;
property ReplaceList: TStringList read FReplaceList write FReplaceList;
property Replacer: TStringList read FReplacer write FReplacer;
published
property AccentIcons: TAccentSet read FIcons write SetIconSet;
property AutoShift: Boolean read FAutoShift write FAutoShift;
property AutoSuggest: Boolean read FAutoSuggest write FAutoSuggest;
property DialogStyle: TDialogTypes read FDialogType write SetDialogType;
property DictionaryName: TFileName read FDictionary write FDictionary;
property DictionaryPath: TFileName read FPath write FPath;
property DictionaryType: TLanguages read FDicType write SetDicType;
property LabelLanguage: TLanguages read FLanguage write SetLanguage;
property Suggestions: Byte read FSuggestions write SetSuggestions;
property HelpContext: THelpContext read FHelpContext write SetHelpContext;
property UserDictionary: TFileName read FUserDCT write FUserDCT;
end; { TSpellDlg }
procedure Register;
implementation
{---- TSpellDlg.Wrapper ----}
constructor TSpellDlg.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
FSpellWin := nil;
FDialogType := dtWordPerfect;
FIcons := [];
FAutoShift := TRUE;
FAutoSuggest := FALSE;
FDictionary := '';
FPath := 'APPLICATIONPATH';
FUserDCT := 'USERDCT.TXT';
FDicType := lgEnglish;
FLanguage := lgEnglish;
SetDialogType (FDialogType);
Suggestions := 10;
end; { TSpellDlg.Create }
destructor TSpellDlg.Destroy;
begin
CloseDictionary;
{FSpellWin is automatically destroyed by parent}
{FSpellWin.Destroy implied}
inherited Destroy;
end; { TSpellDlg.Destroy }
procedure TSpellDlg.SetDicType (NewType: TLanguages);
{-sets the new dictionary type}
begin
FDicType := NewType;
case FDicType of
lgSpanish: Include (FIcons, acSpanish);
end; { case }
end; { TSpellDlg.SetDicType }
procedure TSpellDlg.SetLanguage (NewLanguage: TLanguages);
{-sets the language for the label}
var
LangMesg: string;
begin
FLanguage := NewLanguage;
if FSpellWin <> nil then
FSpellWin.Language := FLanguage;
end; { TSpellDlg.SetLanguage }
procedure TSpellDlg.SetDialogType (NewType: TDialogTypes);
{-sets the dailog type}
var
dtMesg: string;
begin
if csDesigning in ComponentState the